package com.zjdiepu.www.model.base.dto;

import io.swagger.annotations.ApiModelProperty;

import java.util.List;
import java.util.Map;

import javax.validation.GroupSequence;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.alibaba.fastjson.annotation.JSONField;
import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.annotation.Id;
import com.zjdiepu.www.base.annotation.Login;
import com.zjdiepu.www.base.annotation.Update;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.BaseModel;
import com.zjdiepu.www.base.enums.type.LoginType;
import com.zjdiepu.www.model.base.response.Nemu;

/**
 * 用户表<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月05日 15时24分<br/>
 * @since 1.0<br/>
 */
@GroupSequence({Id.class, Login.class, Update.class, Add.class, SysUser.class})
public class SysUser extends BaseModel implements AbstractSysUser
{
	
	private static final long serialVersionUID = 1L;
	/**
	 * 登录用户名称
	 */
	@NotBlank(message="登录名{message.null}",groups={Login.class, Update.class, Add.class})
	@ApiModelProperty(name="loginName",required=true,value="登录名",example="admin")
	private String loginName;
	
	/**
	 * 登录用户密码
	 */
	@NotBlank(message="登录密码{message.null}",groups={Login.class})
	@Null(message="不能传入密码",groups={Id.class, Update.class, Add.class})
	@ApiModelProperty(name="loginPass",required=true,value="登录密码",example="21232f297a57a5a743894a0e4a801fc3")
	private String loginPass;
	
	/**
	 * 用户姓名
	 */
	@NotBlank(message="用户姓名{message.null}",groups={Update.class, Add.class})
	@Length(min = 2, max = 20, message = "用户姓名{message.length}", groups={Update.class, Add.class}) 
	@Pattern(regexp = "[\u4e00-\u9fa5]+", message = "用户姓名{message.chinese}", groups={Update.class, Add.class})
	private String uname;
	
	/**
	 * 手机号码
	 */
	private String phone;
	
	/**
	 * 性别
	 */
	private String sex;
	
	/**
	 * 身份证号码
	 */
	private String identity;
	
	/**
	 * 用户邮箱
	 */
	@Email(message="邮箱格式错误")
	private String mailbox;
	
	/**
	 * 职位编号
	 */
	private String positionId;
	
	/**
	 * 公司编号
	 */
	private String companyId;
	
	/**
	 * 行政部门
	 */
	@NotBlank(message="请选择部门")
	private String orgId;
	
	/**
	 * 部门名称
	 */
	private String orgName;
	
	/**
	 * 部门状态
	 */
	private Integer orgDpStatus;
	
	/**
	 * 连接编号
	 */
	private String connectId;
	
	/**
	 * 公众号标识
	 */
	@Null(message="不能传入公众号标识",groups={Id.class,Login.class, Update.class, Add.class})
	private String openid;
	/**
	 * 开放平台标识
	 */
	@Null(message="不能传入开放平台标识",groups={Id.class,Login.class, Update.class, Add.class})
	private String uinitid;
	
	/**
	 * 登录类型
	 * {@link LoginType}
	 */
	@Null(message="不能传入账号类型",groups={Id.class,Login.class, Update.class, Add.class})
	private Integer loginType;
	/**
	 * 贷款银行
	 */
	private String loanBank;
	
	/**
	 * 头像
	 */
	private String headerImage;
	
	/**
	 * 头像路径
	 */
	private String headerImageSrc;
	
	/**
	 * 账号类型 0.业务员1.非业务员
	 */
	private Integer accountType;
	
	/**
	 * 业务员ID
	 */
	private String salersmanId;
	
	/**
	 * 业务员编码
	 */
	private String salersmanCode;
	
//	===================辅助字段===================
	
	/**
	 * 业务员编码
	 */
	private String salersmanName;
	
	/**
	 * 负责的机构
	 */
	@JSONField(serialize = false)
	private List<String> codeUnits;
	
	/**
	 * 负责的机构
	 */
	private String encodeCodeUnits;
	
	/**
	 * 用户权限
	 */
	@JSONField(serialize = false)
	private Map<String, List<Nemu>> nemus;
	
	/**
	 * 用户APP菜单
	 */
	private Map<String, List<Nemu>> appNemus;
	
	/**
	 * 设备标识
	 */
	private String devicetoken;
	/**
	 * 设备类型
	 */
	private String deviceType;
	
	/**
	 * 贷款银行名称
	 */
	private String loanBankName;
	
	/**
	 * 角色名称
	 */
	private String roleName;
	
	/**
	 * 账号类型 0.业务员1.非业务员
	 */
	private String accountTypeDisplay;
	
	public String getLoginName(){
		return this.loginName;
	}
	
	public void setLoginName(String loginName){
		this.loginName = loginName;
	}

	public String getLoginPass(){
		return this.loginPass;
	}
	
	public void setLoginPass(String loginPass){
		this.loginPass = loginPass;
	}

	public String getUname(){
		return this.uname;
	}
	
	public void setUname(String uname){
		this.uname = uname;
	}

	public String getPhone(){
		return this.phone;
	}
	
	public void setPhone(String phone){
		this.phone = phone;
	}

	public String getSex(){
		return this.sex;
	}
	
	public void setSex(String sex){
		this.sex = sex;
	}

	public String getIdentity(){
		return this.identity;
	}
	
	public void setIdentity(String identity){
		this.identity = identity;
	}

	public String getMailbox(){
		return this.mailbox;
	}
	
	public void setMailbox(String mailbox){
		this.mailbox = mailbox;
	}

	public String getPositionId(){
		return this.positionId;
	}
	
	public void setPositionId(String positionId){
		this.positionId = positionId;
	}

	public String getCompanyId(){
		return this.companyId;
	}
	
	public void setCompanyId(String companyId){
		this.companyId = companyId;
	}

	public String getOrgId(){
		return this.orgId;
	}
	
	public void setOrgId(String orgId){
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public Integer getOrgDpStatus() {
		return orgDpStatus;
	}

	public void setOrgDpStatus(Integer orgDpStatus) {
		this.orgDpStatus = orgDpStatus;
	}

	public String getConnectId(){
		return this.connectId;
	}
	
	public void setConnectId(String connectId){
		this.connectId = connectId;
	}
	
	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public String getLoanBank() {
		return loanBank;
	}

	public void setLoanBank(String loanBank) {
		this.loanBank = loanBank;
	}

	public String getUinitid() {
		return uinitid;
	}

	public void setUinitid(String uinitid) {
		this.uinitid = uinitid;
	}

	public Integer getLoginType() {
		return loginType;
	}

	public void setLoginType(Integer loginType) {
		this.loginType = loginType;
	}
	

	public String getHeaderImage() {
		return headerImage;
	}

	public void setHeaderImage(String headerImage) {
		this.headerImage = headerImage;
	}

	public Integer getAccountType() {
		return accountType;
	}

	public void setAccountType(Integer accountType) {
		this.accountType = accountType;
	}

	@Override
	public String getName() {
		return uname;
	}

	public String getHeaderImageSrc() {
		return headerImageSrc;
	}

	public void setHeaderImageSrc(String headerImageSrc) {
		this.headerImageSrc = headerImageSrc;
	}
	
	public String getSalersmanId() {
		return salersmanId;
	}

	public void setSalersmanId(String salersmanId) {
		this.salersmanId = salersmanId;
	}

	public String getSalersmanCode() {
		return salersmanCode;
	}

	public void setSalersmanCode(String salersmanCode) {
		this.salersmanCode = salersmanCode;
	}
	

	public List<String> getCodeUnits() {
		return codeUnits;
	}

	public void setCodeUnits(List<String> codeUnits) {
		this.codeUnits = codeUnits;
	}

	public Map<String, List<Nemu>> getNemus() {
		return nemus;
	}

	public void setNemus(Map<String, List<Nemu>> nemus) {
		this.nemus = nemus;
	}

	public String getDevicetoken() {
		return devicetoken;
	}

	public void setDevicetoken(String devicetoken) {
		this.devicetoken = devicetoken;
	}

	public String getLoanBankName() {
		return loanBankName;
	}

	public void setLoanBankName(String loanBankName) {
		this.loanBankName = loanBankName;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getSalersmanName() {
		return salersmanName;
	}

	public void setSalersmanName(String salersmanName) {
		this.salersmanName = salersmanName;
	}

	public String getAccountTypeDisplay() {
		return accountTypeDisplay;
	}

	public void setAccountTypeDisplay(String accountTypeDisplay) {
		this.accountTypeDisplay = accountTypeDisplay;
	}
	

	public String getDeviceType() {
		return deviceType;
	}

	public void setDeviceType(String deviceType) {
		this.deviceType = deviceType;
	}

	public Map<String, List<Nemu>> getAppNemus() {
		return appNemus;
	}

	public void setAppNemus(Map<String, List<Nemu>> appNemus) {
		this.appNemus = appNemus;
	}
	
	

	public String getEncodeCodeUnits() {
		return encodeCodeUnits;
	}

	public void setEncodeCodeUnits(String encodeCodeUnits) {
		this.encodeCodeUnits = encodeCodeUnits;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SysUser other = (SysUser) obj;
		if (getId()  == null) {
			if (other.getId() != null)
				return false;
		} else if (!getId().equals(other.getId()))
			return false;
		return true;
	}

	/*  
	*  @author  zhangpp
	*  <p>Title:  toString</p>  
	*  <p>Description:  </p>  
	*  @return  
	*  @see java.lang.Object#toString()  
	*  @version  V1.0
	*/
	@Override
	public String toString() {
		return "SysUser [loginName=" + loginName + ", loginPass=" + loginPass
				+ ", uname=" + uname + ", phone=" + phone + ", sex=" + sex
				+ ", identity=" + identity + ", mailbox=" + mailbox
				+ ", positionId=" + positionId + ", companyId=" + companyId
				+ ", orgId=" + orgId + ", orgName=" + orgName
				+ ", orgDpStatus=" + orgDpStatus + ", connectId=" + connectId
				+ ", openid=" + openid + ", uinitid=" + uinitid
				+ ", loginType=" + loginType + ", loanBank=" + loanBank
				+ ", headerImage=" + headerImage + ", headerImageSrc="
				+ headerImageSrc + ", accountType=" + accountType
				+ ", salersmanId=" + salersmanId + ", salersmanCode="
				+ salersmanCode + ", codeUnits=" + codeUnits + ", nemus="
				+ nemus + ", devicetoken=" + devicetoken + ", deviceType="
				+ deviceType + ", loanBankName=" + loanBankName + ", roleName="
				+ roleName + ", accountTypeDisplay=" + accountTypeDisplay + "]";
	}

}